#pragma once
#ifndef xSprite_h__
#define xSprite_h__
#include "../../../dxhead/dxegheader.h"
#include "../../../xlib/xlib.h"
#include "./xMatrix.h"
#include "xRes.h"
#include "./xDxType.h"
namespace Sky
{
	class xDevice;
	class xPict;
	class xFont;
	class xSprite:public xDeviceRes<LPD3DXSPRITE>
	{
	public:
		xSprite();
		~xSprite();
	public:
		virtual TResult onCreate(xDxApp* app);
		virtual TResult onDelete(xDxApp* app){return XE_OK;};

		TResult onCreate(xDevice* device);
		TResult onReset(xDevice* device);
		TResult onLost(xDevice* device);
		TResult onDelete(xDevice* device);

		TResult begin(TUint D3DXSPRITE_ = D3DXSPRITE_ALPHABLEND);
		TResult draw(xPict* pict,TRect* src = vNull,xVector5* dst = vNull,xVector3* center = vNull,xColor color = D3DCOLOR_RGBA(0xff,0xff,0xff,0xff));
		TResult draw(xPict* pict,TRect* src = vNull,xVector3* dst = vNull,xVector3* center = vNull,xColor color = D3DCOLOR_RGBA(0xff,0xff,0xff,0xff));
		TResult draw(xFont* font,TChar* str,TRect* dst,TInt size = -1,TUint DT_ = DT_LEFT,xColor color = D3DCOLOR_RGBA(0xff,0xff,0xff,0xff));
		TResult draw(TRect* src = vNull,xVector3* dst = vNull,xVector3* center = vNull,xColor color = D3DCOLOR_RGBA(0xff,0xff,0xff,0xff));
		TResult draw(const TChar* str,TRect* dst,TInt size = -1,TUint DT_ = DT_LEFT,xColor color = D3DCOLOR_RGBA(0xff,0xff,0xff,0xff));
		TSize   calTextSize(xFont* font,TChar* str,TRect* dst);
		TVoid	end();
		TResult	attachFont(xFont* font);
		TResult	attachPict(xPict* pict);
		TVoid   detachFont(){m_pFont = vNull;}
		TVoid	detachPict(){m_pPict = vNull;}
		xSprite&	setMatrix(xMatrix* matrix);
		xSprite&	setCenter(TInt x = 0,TInt y = 0,TInt z = 0);
	public:
		LPD3DXSPRITE getSprite(){return getCreatedRes();}
	private:
	private:
		TVoid Initialise();
		TVoid Finalise();
		TBool  m_bBegined;
		xFont* m_pFont;
		xPict* m_pPict;
		TInt	m_CenterX;
		TInt	m_CenterY;
		TInt	m_CenterZ;
		xMatrix m_Transform;
		xMatrix m_Origion;
	};
}
#endif // xSprite_h__